package com.x.mvp.widget.ruler;

import android.graphics.Canvas;
import android.graphics.Paint;

/**
 * Created by H on 18/3/5.
 */

public class LabelRander extends Rander {
    Paint forePan;

    public LabelRander(int foregoundColor, int backgoundColor, int split, int totalLength, int offset) {
        super(foregoundColor, backgoundColor, split, totalLength, offset);
    }

    @Override
    void init() {
        super.init();
        forePan = new Paint();
        forePan.setColor(foregoundColor);
        forePan.setStrokeWidth(2f);
        forePan.setAntiAlias(true);
        forePan.setTextSize(25);
    }

    @Override
    public void onDraw(Canvas canvas) {
        int w = canvas.getWidth();
        int h = canvas.getHeight();
        int[] fir = getFirstScale(w);
        for (int i = 0; i < w / (split * 10); i++) {
            float y = h / 2;
            float x = fir[0] * split + split * 10 * i;
            canvas.drawText((fir[1] + i) * 10 + "", x, y, forePan);
        }
    }
}
